# Replication Package: The Development Threshold: Demographics and the Middle-Income Transition

**Paper 26 in the Demographics & Global Capital Allocation series**
**Brian Peters, March 2026**

---

## Overview

This paper tests whether demographic transition stage predicts middle-income trap escape. Key finding: conditional on entering the $9K-25K zone, demographic transition stage at entry is the strongest predictor of crossing to high-income status, operating through the duration of favorable age structure rather than savings level directly. Uses cross-sectional, survival (Cox/Kaplan-Meier), and panel-in-zone estimation.

## Software Requirements

- Python 3.10+
- Required packages: `numpy`, `pandas`, `statsmodels`, `scipy`, `matplotlib`, `lifelines`, `python-docx`
- Install: `pip install numpy pandas statsmodels scipy matplotlib lifelines python-docx`

## Directory Structure

```
replication/
  REPLICATION_README.md
  scripts/
    phase1_data_construction.py  # Country classification and zone entry/exit
    phase2_cross_sectional.py    # Bivariate and multivariate cross-section
    phase3_survival.py           # Cox proportional hazard and Kaplan-Meier
    phase4_panel_in_zone.py      # Panel estimation within the transition zone
    phase4b_kaopen_change.py     # Capital account opening and transition
    phase5_current_cohort.py     # Current middle-income cohort projections
    phase6_robustness.py         # Robustness (alternative thresholds, controls)
    phase7_final_tests.py        # Additional specification tests
    phase8_revisions.py          # Revision-round robustness
    phase9_round2.py             # Second revision round
    build_docx.py                # DOCX generation
  src/
    model.py                     # PanelGLS estimator (available but not primary)
    demographics.py              # Demographic polynomial construction
  data/processed/
    country_classification.csv   # Country zone classification
    crossing_data.csv            # Zone entry/exit events
    survival_data.csv            # Survival analysis dataset
  output/tables/
    [18 CSV output tables]       # Cross-section, survival, panel results
  paper/
    paper.md                     # Manuscript source
```

## Reproduction

Run scripts in order:
```bash
python3 scripts/phase1_data_construction.py
python3 scripts/phase2_cross_sectional.py
python3 scripts/phase3_survival.py
python3 scripts/phase4_panel_in_zone.py
python3 scripts/phase4b_kaopen_change.py
python3 scripts/phase5_current_cohort.py
python3 scripts/phase6_robustness.py
python3 scripts/phase7_final_tests.py
python3 scripts/phase8_revisions.py
python3 scripts/phase9_round2.py
```

**Note:** Scripts use absolute paths (`/mnt/c/demographics_capital_flows/...`). Update the path references at the top of each script for your local environment. This paper uses `statsmodels` and `lifelines` rather than the custom PanelGLS estimator.

## Data Sources

- UN World Population Prospects (2024 Revision) — age distributions, demographic transition stage
- Penn World Table 10.01 — real GDP per capita (rgdpe/pop), PPP-adjusted
- World Bank — income classifications, WGI governance indicators
- Chinn-Ito KAOPEN — capital account openness
